package com.zsw.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import com.zsw.pojo.User;

@Controller
//@Api(value="test",description="测试接口描述")
//@RequestMapping("/zsw/www")
public class TestController {

	@RequestMapping(value = "/name/{name}", method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation(value = "根据用户名获取用户对象", httpMethod = "GET", response = User.class, notes = "根据用户名获取用户对象")
	public User getUserByName(@ApiParam(required = true, name = "name", value = "用户名") @PathVariable String name)
			throws Exception {
		User user = new User();
		user.setAge(34);
		user.setName("zsw");
		return user;
	}
	@RequestMapping(value = "/name/{age}", method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation(value = "根据用户的年龄获取用户对象", httpMethod = "GET", response = User.class, notes = "根据用名字获取用户对象")
	public User getUserByAge(@ApiParam(required = true, name = "age", value = "年龄") @PathVariable Integer  age)
			throws Exception {
		User user = new User();
		user.setAge(34);
		user.setName("zsw");
		return user;
	}
	@RequestMapping(value = "/name/{name}/{age}", method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation(value = "根据用户名和年龄获取用户对象", httpMethod = "GET", response = User.class, notes = "根据用户名和名字获取用户对象")
	public User getUserByNameAndAge(@ApiParam(required = false, name = "name", value = "用户名") @PathVariable String name,@ApiParam(required = true, name = "age", value = "年龄")@PathVariable Integer  age)
			throws Exception {
		User user = new User();
		user.setAge(34);
		user.setName("zsw");
		return user;
	}
	@RequestMapping(value = "/name/getPojo", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "测试调取对象", httpMethod = "post", response = User.class, notes = "测试调取对象fvef")
	public User getTestPojo(@ApiParam(required = true, name = "user", value = "用户对象")  User user,@ApiParam(required = true, name = "age", value = "年龄") Integer  age)
			throws Exception {
		User users = new User();
		users.setAge(34);
		users.setName("zsw");
		return users;
	}
	@RequestMapping(value = "/index2.html", method = RequestMethod.GET)
	//@ResponseBody
	public String getURL( User user, Integer  age)
			throws Exception {
		User users = new User();
		users.setAge(34);
		users.setName("zsw");
		return "ds";
	}

}
